home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / rexx / FWCalendar.lha / gui4cli.lha / Gui4Cli / Tools / Rtn / Clock.g < prev    next >
Encoding:
Gui4CLI script  |  1998-07-06  |  2.5 KB  |  101 lines

  1. G4C
  2.  
  3. ; Clock.g - see the Routines.guide for details on it's use.
  4. ; ============================================================
  5. ; Note - this gui has no window. The ListView below is used
  6. ; only as a database to keep gui names.
  7. ; ============================================================
  8.  
  9. xListView 0 0 10 10 '' lvar '' 0 NUM
  10. GadID 1
  11.  
  12. ; ============================================================
  13. ; Upon loading, we make sure that rexxmast is available, then
  14. ; we launch the rexx program that will set our variables and
  15. ; wake us up every minute, so we can notify all the guis that
  16. ; have asked to be notified.
  17. ; ============================================================
  18.  
  19. xOnLoad gui
  20.  
  21. ; look for arexx and if not found, launch it..
  22. ifexists port AREXX
  23.    ; ok..
  24. else
  25.    run 'rexxmast'
  26.    wait port AREXX 50
  27.    if $$retcode > 0
  28.       ezreq 'Could not launch RexxMast!' Quit ''
  29.       guiquit clock.gc
  30.       stop
  31.    endif
  32. endif
  33.  
  34. ; register the gui they sent us
  35. gosub clock.g add $gui
  36.  
  37. ; Load the Clock.rexx program which is kept in the rexx dir
  38. sendrexx AREXX 'Guis:tools/rexx/Clock.rexx clock.g update'
  39.  
  40.  
  41. ; ============================================================
  42. ;      On re-loading - add the gui..
  43. ; ============================================================
  44.  
  45. xONRELOAD gui
  46. gosub clock.g add $gui
  47.  
  48.  
  49. ; ============================================================
  50. ; This is the routine that the rexx program we launched will
  51. ; call every minute, after it has set our variables.
  52. ; We, in turn, call all the guis that have asked us to.
  53. ; ============================================================
  54.  
  55. XRoutine update
  56. lvuse clock.g 1
  57. if $$lv.total = 0    ; no guis - quit
  58.    guiquit clock.g
  59.    stop
  60. endif
  61. lvgo first
  62. while $$lv.line > ''
  63.    GoSub $gui clock    ; call the clock routine in all guis
  64.    lvuse clock.g 1    ; because some other gui may change it  
  65.    lvgo next
  66. endwhile
  67.  
  68.  
  69. ; ============================================================
  70. ;      Add a gui to the list
  71. ; ============================================================
  72.  
  73. xROUTINE add gui
  74. if $gui > " "
  75.    lvuse clock.g 1
  76.    lvsearch $gui ci first
  77.    if $$lv.line = ""         ; add if it doesn't already exist
  78.       lvadd '$gui'
  79.    endif
  80. else
  81.    ezreq "You MUST give a gui name" OK ''
  82. endif
  83.  
  84.  
  85. ; ============================================================
  86. ;       Remove a gui
  87. ; ============================================================
  88.  
  89. xROUTINE remove gui
  90. if $gui > ""
  91.    lvuse clock.g 1
  92.    lvsearch $gui ci first
  93.    if $$lv.line > ""         ; remove if it exists
  94.       lvdel -1
  95.    endif
  96. endif
  97.  
  98.  
  99.  
  100.  
  101.